
// out vec4 gl_FragColor;
// in vec2 gl_FragCoord;

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform float u_time;

 //画布
vec2 PrepareCanvas(float num){
    //画布原点移动到中央  并且不随外部画布拉伸 
    //默认以短轴为基准 num=1.0
    vec2 uv=num*(2.*gl_FragCoord.xy-u_resolution)/
            min(u_resolution.x,u_resolution.y);
    return uv;
}
//网格
vec3 MakeGrid(vec2 uv){
    
    vec3 col=vec3(0.);
    
    vec2 cell=fract(uv);
    if(cell.x<.001)
    {
        col=vec3(1.);
    }
    if(cell.y<.001)
    {
        col=vec3(1.);
    }
    return col;
    
    // color.r+=step(.98,sin(30.*uv.x));
    // color.r+=step(.98,cos(30.*uv.x));
}
  //坐标轴
vec3 MakeAxis(vec2 uv){
    vec3 color=vec3(0.);//
    color.r+=step(-.2,-abs(uv.x));
    color.g+=step(-.2,-abs(uv.y));
    return color;
}

void main(){
     
    vec2 uv= PrepareCanvas(5.); 

    vec3 color=vec3(0.); 
    //坐标轴
    color+=MakeAxis(uv);
    //网格
    color+=MakeGrid(uv); 

    
    gl_FragColor=vec4(color,1.);
    
}